package helper.com.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

import static helper.com.constants.RabbitmqConstants.*;

/**
 * @author 大忽悠
 * @create 2022/5/18 11:18
 */
@Configuration
public class RabbitConfig {

   //--------------------EXCHANGE--------------------------

   @Bean
   public DirectExchange managerExchange()
   {
       return new DirectExchange(MANAGER_EXCHANGE);
   }

   //--------------------QUEUE--------------------------

    @Bean
    public Queue managerQueue()
    {
        return QueueBuilder.durable(MANAGER_QUEUE).build();
    }

   //--------------------bind--------------------------

    @Bean
    public Binding queueBindingExchange(@Qualifier("managerQueue") Queue managerQueue,
                                        @Qualifier("managerExchange")DirectExchange managerExchange)
    {
        return BindingBuilder.bind(managerQueue).to(managerExchange).with(MANAGER_ROUTE_KEY);
    }

}
